// 引入本地存储
import { setToken, getToken } from '@/utils/auth'
import { loginAPI } from '@/api/user'
const state = {
  token: getToken()
}
const mutations = {
  setUserToken(state, token) {
    state.token = token
  }
}
const actions = {
  async loginAction(ctx, loginForm) {
    const token = await loginAPI(loginForm)
    // console.log(loginForm)
    // const token = '88888'
    console.log(token, loginForm, 'user')
    ctx.commit('setUserToken', token)
    setToken(token)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
